package com.yao.utils;

import lombok.Data;

import java.util.ArrayList;

/**
 * 统一的结果返回封装（异步返回）
 *
 * @author
 * @create 2018-09-27 10:32
 **/
@Data
public class Result {

    private String code;
    private String message;
    private Object data;

    public static Result succ(String message) {
        Result result = new Result();
        result.setCode("200");
        result.setData(null);
        result.setMessage(message);

        return result;
    }

    public static Result succ(String message, Object data) {
        Result result = new Result();
        result.setCode("200");
        result.setData(data);
        result.setMessage(message);

        return result;
    }

    public static Result fail(String message) {
        Result result = new Result();
        result.setCode("400");
        result.setData(null);
        result.setMessage(message);

        return result;
    }

    public static Result fail(String message, Object data) {
        Result result = new Result();
        result.setCode("400");
        result.setData(data);
        result.setMessage(message);

        return result;
    }
}
